<?php
    include('./library/conn.php');

    $username=$_REQUEST['user-name'];
    $userpw=$_REQUEST['user-pw'];
    $select="select username from users where (username='$username' or phone='$username' or email='$username') and password='$userpw'";
    $result=$mysqli->query($select);
    if($result->num_rows>0){
            $res=$result->fetch_assoc();
            $username=$res['username'];
            echo "<script>alert('登录成功！，即将进入首页');document.cookie='user=$username;path=/';</script>";
            echo '<script>location.href="../src/html/index.html";</script>';
            $mysqli->close();  //关闭数据库连接
            die();//终止代码
    }
    echo '<script>alert("登录失败，即将返回登录页");</script>';
    echo '<script>location.href="../src/html/login.html";</script>';
    $mysqli->close();  //关闭数据库连接
?>